<?php
/**************************** SERVICE INITIALIZATION BEGINS ****************************/
require_once("../../config.php");
require_once(ML_ROOT."/service-admin.php"); on_comments();

$comment_list = isset($view_data[Protocol::COMMENT_LIST]) ? $view_data[Protocol::COMMENT_LIST] : NULL;
/***************************** SERVICE INITIALIZATION ENDS *****************************/
?>

<?php
/********************************* HTML CONTENT BEGINS *********************************/
require_once(ML_INCLUDE."/admin-header.php");
?>
	<h1>Comments</h1>
	<a href="<?=url("/admin/comments-edit.php")?>">Create Comment</a>
	<form action="<?=url("/admin/comments.php")?>" method="post">
	<table>
		<tr>
			<th><input type="checkbox" /></th>
			<th>id</th>
			<th>user_name</th>
			<th>model_id</th>
			<th>comment</th>
			<th>created_time</th>
			<th>likes</th>
		</tr>
		<?php if(count($comment_list) > 0) : ?>
		<?php foreach($comment_list as $comment): ?>
		<tr>
			<td><input type="checkbox" name="<?=Protocol::SELECTIONS."[]"?>" value="<?=$comment[Protocol::ID]?>" /></td>
			<td><a href="<?=url("/admin/comments-edit.php?id=".$comment[Protocol::ID])?>"><?=$comment[Protocol::ID]?></a></td>
			<td><?=$comment[Protocol::USER_NAME]?></td>
			<td><?=$comment[Protocol::MODEL_ID]?></td>
			<td><?=$comment[Protocol::COMMENT]?></td>
			<td><?=$comment[Protocol::CREATED_TIME]?></td>
			<td><?=$comment[Protocol::LIKES]?></td>
		</tr>
		<?php endforeach ?>
		<?php else : ?>
		<tr><td colspan="7">No Comment</td></tr>
		<?php endif ?>
		<tr>
			<td colspan="7">
				<button name="<?=Protocol::SUBMIT?>" type="submit" value="<?=Protocol::DELETE?>">Delete</button>
			</td>
		</tr>
	</table>
	</form>
<?php
require_once(ML_INCLUDE."/admin-footer.php");
/********************************** HTML CONTENT ENDS **********************************/
?>